package lab03.test01;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/**
 * Created by AIR on 2017/11/16.
 */

public class Test02 {
    public static void main(String[] args) {
        //字符流 读文件
        String path="D:\\hello.txt";
        BufferedReader reader=null;
        try {
            reader = new BufferedReader(new FileReader(path));//实例化

//            String line="";//定义一个line变量
//
//            line=reader.readLine();//把读取到的字符放在line变量里面
//
//            System.out.println(line);
            //用一个循环
            String line=null;
            while ((line=reader.readLine())!=null){
                System.out.println(line);
            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                reader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
